import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;


public class WordReverse {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNext()) {
            String str = s.nextLine();
            String[] strs = str.split(" ");
            Deque<String> queue = new LinkedList<>();
            for(String st : strs) {
                char[] chars = st.toCharArray();
                for(int i = 0; i < chars.length; i++) {
                    if((chars[i] - 'a' >= 0 && chars[i] - 'a' <= 25) || (chars[i] - 'A' >= 0 && chars[i] - 'A' <= 25)) {
                        StringBuilder sb = new StringBuilder();
                        while(i < chars.length && ((chars[i] - 'a' >= 0 && chars[i] - 'a' <= 25) || (chars[i] - 'A' >= 0 && chars[i] - 'A' <= 25))) {
                            sb.append(chars[i]);
                            i++;
                        }
                        queue.addFirst(sb.toString());
                    }
                }
            }
            while(!queue.isEmpty()) {
                if(queue.size() != 1) {
                    System.out.print(queue.poll() +" ");
                }else {
                    System.out.println(queue.poll());
                }
            }
        }
    }
}
